package a2025_04_06;

import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;

import java.util.HashSet;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Set;

public class min_genetic_mutation {
    public static void main(String[] args) {
        char[] letter=new char[]{'A','C','G','T'};
        System.out.println(letter.toString());
        String startGene = "AACCGGTT";

        String endGene = "AACCGGTA";
        String[] bank = new String[]{"AACCGGTA"};
        Set<String> desc=new HashSet<>();
        Set<String> visit=new HashSet<>();

        for(String x:bank){
            desc.add(x);
        }

        if(!desc.contains(endGene)) ;

        Queue<String> queue=new LinkedList<>();
        queue.add(startGene);
        visit.add(startGene);

        int ret=0;
        while(!queue.isEmpty()){
            ret++;
            int sz=queue.size();
            while(sz-->0){
                String temp=queue.poll();
                for(int i=0;i<temp.length();i++){
                    char[] arr=temp.toCharArray();
                    for(char x:letter){
                        arr[i]=x;
                        String change=arr.toString();
                        if(change.equals(endGene)){
                            System.out.println(ret);
                            break;
                        }
                        if(desc.contains(change)&&!visit.contains(change)){
                            visit.add(change);
                            queue.add(change);
                        }
                    }
                }
            }
        }
        System.out.println(ret+"==============");
    }
}
